﻿using System.Linq;
using DynCMS.NET.Core.Entities;
using DynCMS.NET.Core.Entities.Base;

namespace DynCMS.NET.Core.Interfaces
{
    public interface IDataRepository<T> where T : PersistableEntity
    {
        bool ReturnPocoObjects { get; set; }

        /// <summary>
        /// Gets all.
        /// </summary>
        /// <returns></returns>
        IQueryable<T> GetAll();

        /// <summary>
        /// Gets all.
        /// </summary>
        /// <param name="includeInactive">if set to <c>true</c> [include inactive].</param>
        /// <returns>List of all entities</returns>
        IQueryable<T> GetAll(bool includeInactive);

        /// <summary>
        /// Gets the entity specified by key value in entity object.
        /// </summary>
        /// <param name="key">Entity containing key values for target entity.</param>
        /// <returns></returns>
        T Get(T key);

        /// <summary>
        /// Creates the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns>Created entity</returns>
        T Create(T entity);

        /// <summary>
        /// Updates the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns>Updated entity</returns>
        T Update(T entity);

        /// <summary>
        /// Creates the or updates.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        T CreateOrUpdate(T entity);

        /// <summary>
        /// Deletes the specified entity.
        /// </summary>
        /// <param name="entity">The entity to delete.</param>
        /// <returns>Deleted entity</returns>
        void Delete(T entity);

        /// <summary>
        /// Saves the changes.
        /// </summary>
        /// <returns></returns>
        int SaveChanges();
    }
}